package com.zhss.demo.redisson;


import org.redisson.api.RSemaphore;
import org.redisson.api.RedissonClient;

import java.util.concurrent.TimeUnit;

public class SemaphoreDemo {
    public static void main(String[] args) throws InterruptedException {
        RedissonClient redisson = RedissionHelp.getRedissionClient();
        RSemaphore semaphore = redisson.getSemaphore("semaphore");
        semaphore.trySetPermits(20);
        semaphore.acquire();
//或
//        semaphore.acquireAsync();
//        semaphore.acquire(23);
//        semaphore.tryAcquire();
////或
//        semaphore.tryAcquireAsync();
//        semaphore.tryAcquire(23, TimeUnit.SECONDS);
////或
//        semaphore.tryAcquireAsync(23, TimeUnit.SECONDS);
//        semaphore.release(10);
//        semaphore.release();
////或
//        semaphore.releaseAsync();

        RedissionHelp.wait(semaphore, redisson);
    }


}
